package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //mysql8.0
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:8164/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "123457");
        System.out.println("连接成功");

        Statement stmt = conn.createStatement();
        String sql = "CREATE TABLE user(" +
                "id INT PRIMARY KEY AUTO_INCREMENT," +
                "username VARCHAR(30)," +
                "password VARCHAR(30)," +
                "nickname VARCHAR(30)," +
                "age INT(3)" +
                ")";
        stmt.execute(sql);
        System.out.println("创建成功");

        conn.close();

    }
}
